<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="utf-8">
	<title>添加</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport"
		content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
	<link rel="stylesheet" href="/layui/css/layui.css">
	<link rel="stylesheet" href="/src/css/public.css">
</head>

<body>
	<div style="padding: 10px;">
		<form class="layui-form" action="" lay-filter="addForm">
			<ul class="layui-form layui-form-pane formUl" style="margin: 15px;OVERFLOW: HIDDEN;">
				<li class="layui-form-item" >
					<label class="layui-form-label"><i class="layui-form-i"> * </i>项目类型</label>
					<div class="layui-input-block">
						<select id="itemflag" name="itemflag" lay-filter="itemflag">
							<option value="0" selected="">检查项</option>
							<option value="1">判定项</option>
							<option value="2">原因项</option>
						</select>
					</div>
				</li>
				<li class="layui-form-item" id="divdaim">
					<label class="layui-form-label">项目代码 </label>
					<div class="layui-input-block">
						<input type="text" name="daim" autocomplete="off" placeholder="请输入代码（标准里的代码值）"
							class="layui-input">
					</div>
				</li>
				<li class="layui-form-item">
					<label class="layui-form-label"><i class="layui-form-i"> * </i>检查项目序号</label>
					<div class="layui-input-block">
						<input type="text" name="itemnumber" lay-verify="required" autocomplete="off"
							placeholder="请输入检查项目的序号" class="layui-input">
					</div>
				</li>
				<li class="layui-form-item">
					<label class="layui-form-label"><i class="layui-form-i"> * </i>检查项目名称</label>
					<div class="layui-input-block">
						<input type="text" name="itemname" lay-verify="required" autocomplete="off"
							placeholder="请输入检查项目的名称" class="layui-input">
					</div>
				</li>

				<li class="layui-form-item" id="divisproblem" style="width: 98%;">
					<label class="layui-form-label"><i class="layui-form-i"> * </i>判定类型</label>
					<div class="layui-input-block">
						<input type="radio" name="isproblem" value="0" title="未发现问题" checked="">
						<input type="radio" name="isproblem" value="8" title="合理缺项">
						<input type="radio" name="isproblem" value="9" title="发现问题">
					</div>
				</li>

				<li class="layui-form-item layui-form-text" id="divjcyj">
					<label class="layui-form-label">检查依据</label>
					<div class="layui-input-block">
						<textarea type="text" name="jcyj" autocomplete="off" placeholder="请输入检查项的检查依据"
							class="layui-textarea"></textarea>
					</div>
				</li>
				<li class="layui-form-item layui-form-text" id="divjcfs">
					<label class="layui-form-label">检查方式</label>
					<div class="layui-input-block">
						<textarea type="text" name="jcfs" autocomplete="off" placeholder="请输入检查项的检查方式"
							class="layui-textarea"></textarea>
					</div>
				</li>
				<li class="layui-form-item layui-form-text" id="divjczn">
					<label class="layui-form-label">检查指南</label>
					<div class="layui-input-block">
						<textarea type="text" name="jczn" autocomplete="off" placeholder="请输入检查项的检查指南"
							class="layui-textarea"></textarea>
					</div>
				</li>
				<li class="layui-form-item layui-form-text" id="divcfyj">
					<label class="layui-form-label">处罚依据</label>
					<div class="layui-input-block">
						<textarea type="text" name="cfyj" autocomplete="off" placeholder="请输入处罚依据"
							class="layui-textarea"></textarea>
					</div>
				</li>
				<li class="layui-form-item" id="divisvoteitem">
					<label class="layui-form-label"><i class="layui-form-i"> * </i>是否是否决项</label>
					<div class="layui-input-block" style="border: 1px solid #eee;">
						<input type="radio" name="isvoteitem" value="0" title="否" checked="">
						<input type="radio" name="isvoteitem" value="1" title="是">
					</div>
				</li>
				<li class="layui-form-item">
					<label class="layui-form-label"><i class="layui-form-i"> * </i>排序</label>
					<div class="layui-input-block">
						<input type="text" name="paixu" lay-verify="required" autocomplete="off" placeholder="请输入排序"
							class="layui-input">
					</div>
				</li>
			</ul>

			<div style="text-align: center;  ">
				<button type="button" class="layui-btn" lay-submit id="YjbtnSave" lay-filter="YjbtnSave">添加</button>
			</div>
		</form>
	</div>
	<script src="/layui/layui.js"></script>
	<script>
		layui.use(function () {
			var form = layui.form
				, admin = parent.layui.admin
				, table = parent.layui.table;
			var $ = layui.$;
			$('#divisproblem').hide();

			form.on('select(itemflag)', function (data) {
				var val = data.value;
				if (val === "0") {
					$('#divdaim').show();
					$('#divscore').show();
					$('#divisvoteitem').show();
					$('#divisproblem').hide();

					$('#divjcfs').show();
					$('#divjczn').show();
					$('#divjcyj').show();
					$('#divcfyj').show();
				}
				else if (val === "1") {
					$('#divdaim').hide();
					$('#divscore').hide();
					$('#divisvoteitem').hide();
					$('#divisproblem').show();

					$('#divjcfs').hide();
					$('#divjczn').hide();
					$('#divjcyj').hide();
					$('#divcfyj').hide();
				}
				else if (val === "2") {
					$('#divdaim').hide();
					$('#divscore').hide();
					$('#divisvoteitem').hide();
					$('#divisproblem').hide();

					$('#divjcfs').hide();
					$('#divjczn').hide();
					$('#divjcyj').hide();
					$('#divcfyj').hide();
				}
			});

			//添加
			form.render().on('submit(YjbtnSave)', function (data) {
				data.field.jcxmflag = layui.data(parent.layui.setter.tableName)['jcxmflag'];
				data.field.parentid = layui.data(parent.layui.setter.tableName)['jcxmpid'];
				if (data.field.isvoteitem == "1")
					data.field.score = '5'
				else
					data.field.score = '1'
				admin.req({
					url: 'jdjc/jcxm/Add'
					, data: JSON.stringify(data.field)
					, contentType: 'application/json'
					, type: 'post'
					, done: function (res) {
						if (res.successful) {
							admin.msg_success(res.msg)
						}
						else {
							admin.msg_error(res.msg);
						}
					}
				});
			})
		});
	</script>
</body>

</html>